﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.SqlClient;
using System.Data.SqlClient;
using System.Data;

namespace EZCRS.HCMS.Bll.presentinfo
{
    public class Bllpresentinfo
    {
        private string SqlStr = "";
        #region 礼品数据列表
        public DataSet Present_List(int PageSize, int PageIndex, string StrWhere)
        {
            return new sql_AdmPresent().Present_List(PageSize, PageIndex, StrWhere);
        }
        #endregion
        #region 礼品Info数据的显示,显示一条数据
        public DataRow Present_Item(string PrsId, int GId)
        {
            return new sql_AdmPresent().Present_Item(PrsId, GId);
        }
        #endregion
        #region 礼品的添加、修改
        /// <summary>
        /// 修改或添加礼品
        /// </summary>
        /// <returns></returns>
        public bool Present_Add(string Gid, string Pid, string Prsname, string Simg, string Bimg, string Prsunit, decimal Prsprice, string Prsprovider, string Prsscore, string Prscomment, string Startdate, string Enddate, string Prscount, string Prstype, string Prsstatus, string Indate, string Inuser, string Modidate, string Modiuser, string Prsid,string psid,int languageid)
        {
            return new sql_AdmPresent().Present_Add(Gid, Pid, Prsname, Simg, Bimg, Prsunit, Prsprice, Prsprovider, Prsscore, Prscomment, Startdate, Enddate, Prscount, Prstype, Prsstatus, Indate, Inuser, Modidate, Modiuser, Prsid,psid,languageid);
        }
        #endregion
        #region 礼品的删除
        public bool Present_Del(string Prsid)
        {
            return new sql_AdmPresent().Present_Del(Prsid);
        }
        #endregion
        #region 礼品申请列表
        public DataSet PresentConsume_List(int PageSize, int PageIndex, string StrWhere)
        {
            return new sql_AdmPresent().PresentConsume_List(PageSize, PageIndex, StrWhere);
        }
        #endregion
        #region 礼品申请Info数据的显示,显示一条数据
        public DataRow PresentConsume_Item(string ConId, int GId)
        {
            return new sql_AdmPresent().PresentConsume_Item(ConId, GId);
        }
        #endregion
        #region 礼品申请的状态的改变，以及处理信息的补充
        /// <summary>
        /// 礼品申请的状态的改变，以及处理信息的补充
        /// </summary>
        /// <returns></returns>
        public bool PresentConsume_Add(string Prstype, string Modiuser, string Modidate, string Modicomment, string Conid)
        {
            return new sql_AdmPresent().PresentConsume_Add(Prstype, Modiuser, Modidate, Modicomment, Conid);
        }
        #endregion
        #region 礼品申请的删除
        public bool PresentConsume_Del(string Conid)
        {
            return new sql_AdmPresent().PresentConsume_Del(Conid);
        }
        #endregion

        #region 用了事务，礼品申请处理通过,把礼品状态改为5,往系统日志表里插入记录,因为成功申请后扣积分,所以插负数的
        public bool PresentConsume_Success(string Modiuser, string Modidate, string Modicomment, string Uid, string Conid)
        {
            return new sql_AdmPresent().PresentConsume_Success(Modiuser, Modidate, Modicomment, Uid, Conid);
        }
        #endregion
        #region 用了事务，礼品申请处理失败,把礼品状态改为4，更新hfg_user表里和这个用户对应的积分，增加相应的积分
        public bool PresentConsume_Failure(string Modiuser, string Modidate, string Modicomment, string Uid, string Conid)
        {
            if (new sql_AdmPresent().PresentConsume_Failure(Modiuser,Modidate,Modicomment,Uid,Conid))
            {
                Bll.userinfo.Bllcardinfo.statscore(Convert.ToInt32(Uid), 9);
                return true;
            }
            else
                return false;
        }
        #endregion
        /// <summary>
        /// 重置奖品申请
        /// </summary>
        /// <param name="Modiuser"></param>
        /// <param name="Modidate"></param>
        /// <param name="Modicomment"></param>
        /// <param name="Uid"></param>
        /// <param name="Score"></param>
        /// <param name="Conid"></param>
        /// <returns></returns>
        public bool PresentConsume_Reset(string Modiuser, string Modidate, string Modicomment, string Uid, string Conid)
        {
            if (new sql_AdmPresent().PresentConsume_Reset(Modiuser,Modidate,Modicomment,Uid,Conid))
            {
                Bll.userinfo.Bllcardinfo.statscore(Convert.ToInt32(Uid), 9);
                return true;
            }
            else
                return false;
        }


        public bool PresentConsume_Comment(string Modiuser, string Modidate, string Modicomment, string Conid)
        {
            return new sql_AdmPresent().PresentConsume_Comment(Modiuser, Modidate, Modicomment, Conid);
        }
    }

    public class BllAdmPresentSort
    {
        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="sidlist">所有分类 ,分隔</param>
        /// <returns></returns>
        public bool delsort(string sidlist)
        {
            sidlist = CFun.VerifySQL(sidlist);
            return new sql_AdmPresentSort().delsort(sidlist);
        }

        /// <summary>
        /// 保存分类
        /// </summary>
        /// <param name="sname">分类名</param>
        /// <param name="sid">分类编号 非 0 为修改</param>
        /// <returns></returns>
        public bool savesort(string sname, int sid, int gid, int pid,int languageid)
        {
            return new sql_AdmPresentSort().savesort(sname, sid, gid, pid,languageid);
        }

        /// <summary>
        /// 保存类别排序
        /// </summary>
        /// <param name="sidlist"></param>
        /// <returns></returns>
        public bool saverank(string sidlist)
        {
            return new sql_AdmPresentSort().saverank(sidlist);
        }

        /// <summary>
        /// 返回所有类别数据
        /// </summary>
        /// <param name="gid"></param>
        /// <param name="pid"></param>
        /// <returns></returns>
        public DataTable allsort(int gid, int pid,int languageid)
        {
            return new sql_AdmPresentSort().allsort(gid, pid, languageid);
        }

        public object allsort(int gid,int languageid)
        {
            return new sql_AdmPresentSort().allsort(gid,languageid);
        }
    }
}
